{$CLEO .cs}
{$USE file}
{$USE ini}

//-------------MAIN---------------
thread 'REGEN' 

:REGENERATE_1a  //regen
wait 0
if
056D:   actor $PLAYER_ACTOR defined
else_jump @REGENERATE_1a
read_int_from_ini_file 11@ = read_int_from_ini_file "CLEO/regen.ini" section "Settings" key "SlowRegen" 
read_int_from_ini_file 12@ = read_int_from_ini_file "CLEO/regen.ini" section "Settings" key "FastRegen" 
read_int_from_ini_file 13@ = read_int_from_ini_file "CLEO/regen.ini" section "Settings" key "DelayTime" 
read_float_from_ini_file 14@ = read_float_from_ini_file "CLEO/regen.ini" section "Settings" key "Limit" 
1@ = Actor.Health($PLAYER_ACTOR)
0085: 2@ = 1@ // (int)
0085: 20@ = 1@ // (int)
008F: 21@ = integer 20@ to_float
0653: 7@ = float_stat 24
7@ -= 570.0
7@ *= 0.1767
7@ += 100.0 //matched to integer health value, example--> 100.0 = 100
006B: 7@ *= 14@ // (float)  regen limit
0092: 17@ = float 7@ to_integer
if
803B:   not 1@ == 17@  // (int)
else_jump @REGENERATE_1a
if
001D:   17@ > 1@  // (int)
else_jump @REGENERATE_1a
3@ = 1  //repeater
jump @REGENERATE_1d

:REGENERATE_1b  //------------------------------------>>>>>>>REGEN LOOP
wait 0
read_int_from_ini_file 11@ = read_int_from_ini_file "CLEO/regen.ini" section "Settings" key "SlowRegen" 
read_int_from_ini_file 12@ = read_int_from_ini_file "CLEO/regen.ini" section "Settings" key "FastRegen" 
read_int_from_ini_file 13@ = read_int_from_ini_file "CLEO/regen.ini" section "Settings" key "DelayTime" 
read_float_from_ini_file 14@ = read_float_from_ini_file "CLEO/regen.ini" section "Settings" key "Limit" 
read_float_from_ini_file 15@ = read_float_from_ini_file "CLEO/regen.ini" section "Settings" key "AddAmount" 
0653: 7@ = float_stat 24
7@ -= 570.0
7@ *= 0.1767
7@ += 100.0 //matched to integer health value, example--> 100.0 = 100
006B: 7@ *= 14@ // (float)  regen limit
0087: 10@ = 7@ // (float)
0092: 17@ = float 7@ to_integer
006B: 10@ *= 15@ // (float)  Add Amount
if or
   Actor.Animation($PLAYER_ACTOR) == "WEAPON_CROUCH"
00DF:   actor $PLAYER_ACTOR driving
else_jump @REGENERATE_1b2
if
   not Actor.Animation($PLAYER_ACTOR) == "GUNCROUCHFWD"
else_jump @REGENERATE_1b2
if
   not Actor.Animation($PLAYER_ACTOR) == "GUNCROUCHBWD"
else_jump @REGENERATE_1b2
000A: 3@ += 1   //------------------------------------->>>>>>>regen loop FAST
if or   //if repeater surpass the required value (speed regen)
001D:   3@ > 12@  // (int)
003B:   3@ == 12@  // (int)
else_jump @REGENERATE_1b
3@ = 1  //repeater
jump @REGENERATE_1b_HEAL

:REGENERATE_1b2
000A: 3@ += 1   //------------------------------------->>>>>>>regen loop SLOW
if or   //if repeater surpass the required value (slow regen)
001D:   3@ > 11@  // (int)
003B:   3@ == 11@  // (int)
else_jump @REGENERATE_1b
3@ = 1  //repeater
jump @REGENERATE_1b_HEAL

:REGENERATE_1b_HEAL     //----------------------------->>>>>>>REGEN HEAL
if
   not Actor.Dead($PLAYER_ACTOR)
else_jump @REGENERATE_1a
1@ = Actor.Health($PLAYER_ACTOR)
if
003B:   2@ == 1@  // (int)
else_jump @REGENERATE_1c
if  //if current health still below regen limit
001D:   17@ > 1@  // (int)
else_jump @REGENERATE_1a
005B: 21@ += 10@  // (float)
0092: 20@ = float 21@ to_integer
Actor.Health($PLAYER_ACTOR) = 20@
1@ = Actor.Health($PLAYER_ACTOR)
0085: 2@ = 1@ // (int)
if
803B:   not 1@ == 17@  // (int)
else_jump @REGENERATE_1a
if  //if current health surpass regen limit
001D:   1@ > 17@  // (int)
else_jump @REGENERATE_1b
Actor.Health($PLAYER_ACTOR) = 17@
1@ = Actor.Health($PLAYER_ACTOR)
0085: 2@ = 1@ // (int)
jump @REGENERATE_1a     //----------------------------->>>>>>>REGEN LIMIT reached

:REGENERATE_1c  //------------------------------------->>>>>>>delay regen timer
if
001D:   2@ > 1@  // (int)
else_jump @REGENERATE_1_commit_regen    //undo delay if health increased (consumed food or drink)
1@ = Actor.Health($PLAYER_ACTOR)
0085: 2@ = 1@ // (int)
3@ = 1  //repeater
jump @REGENERATE_1d

:REGENERATE_1d  //------------------------------------->>>>>>>DELAY regen loop
wait 0
if
056D:   actor $PLAYER_ACTOR defined
else_jump @REGENERATE_1a
1@ = Actor.Health($PLAYER_ACTOR)
if
003B:   2@ == 1@  // (int)
else_jump @REGENERATE_1c    //------------------------->>>>>>>RESET delay regen timer
000A: 3@ += 1
if
001D:   3@ > 13@  // (int)
else_jump @REGENERATE_1d
1@ = Actor.Health($PLAYER_ACTOR)
0085: 2@ = 1@ // (int)
0085: 20@ = 1@ // (int)
008F: 21@ = integer 20@ to_float
jump @REGENERATE_1_commit_regen     //----------------------------->>>>>>>COMMIT regen

:REGENERATE_1_commit_regen  //------------------------->>>>>>>COMMIT regen
1@ = Actor.Health($PLAYER_ACTOR)
0085: 2@ = 1@ // (int)
0085: 20@ = 1@ // (int)
008F: 21@ = integer 20@ to_float
jump @REGENERATE_1b
